﻿using System;
using System.Text;
using System.Data;
using System.Collections.Generic;
using Word_Learner_3.Web;

namespace Word_Learner_3.Model
{
    class Meta
    {
        private string key;

        public string Key
        {
            get { return key; }
            set { key = value; }
        }
        private string name;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        private int orderId;

        public int OrderId
        {
            get { return orderId; }
            set { orderId = value; }
        }

        private int wordCount;

        public int WordCount
        {
            get { return wordCount; }
            set { wordCount = value; }
        }
        private int unitCount;

        public int UnitCount
        {
            get { return unitCount; }
            set { unitCount = value; }
        }
        private  Meta getMeta(DataRow dr)
        {
            Meta meta = new Meta();
            meta.Key = dr["Key"].ToString();
            meta.Name = dr["Name"].ToString();
            meta.OrderId = int.Parse(dr["OrderId"].ToString());
            meta.WordCount = int.Parse(dr["WordCount"].ToString());
            meta.UnitCount = int.Parse(dr["UnitCount"].ToString());
            return meta;
        }
        public  List<Meta> getMetas()
        {
            List<Meta> metaList = new List<Meta>();
            DataSet ds = DBHelper.ExecuteDataset("select * from Meta");
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                metaList.Add(getMeta(ds.Tables[0].Rows[i]));

            }
            return metaList;

        }

    }
}
